#! /usr/bin/runghc

import Data.Binary.Put
import Data.IFF
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Lazy as BL

hotCol = [ [ 0x00, 0x00, 0x00 ]
         , [ 0xff, 0x00, 0x00 ]
         , [ 0xff, 0x00, 0x00 ]
         , [ 0xff, 0x00, 0x00 ]
         , [ 0xff, 0x00, 0x00 ]
         , [ 0xff, 0xff, 0x00 ]
         , [ 0xff, 0xff, 0x00 ]
         , [ 0xff, 0xff, 0x00 ]
         , [ 0xff, 0xff, 0x00 ]
         , [ 0xfc, 0xfc, 0xfc ] ]


coolCol = [ [ 0x00, 0x02, 0x0b ]
          , [ 0x00, 0x00, 0x5b ]
          , [ 0x00, 0x00, 0xab ]
          , [ 0x00, 0xa0, 0x70 ]
          , [ 0x00, 0xd0, 0xd0 ]
          , [ 0xdc, 0xf0, 0xf0 ] ]
  
chunkHot = Cons (chunkIdFromString "CMAP") $ Chunk $ B.pack $ concat hotCol
chunkCool = Cons (chunkIdFromString "CMAP") $ Chunk $ B.pack $ concat coolCol
chunkMDOT = Cons (chunkIdFromString "MDOT") $ Chunk $ B.concat $ BL.toChunks $ runPut f
  where f = do putWord32be 0x21000

formSparkles = Cons (chunkIdFromString "SPRK") $ Form [ chunkHot, chunkCool, chunkMDOT ]

chunkAnnotation = Cons (chunkIdFromString "ANNO") $ Chunk $ BC.pack "Rockdodger data file"

main = B.putStr $ toByteString $ Cons (chunkIdFromString "ROCK") $ Form chunks
  where chunks = [ chunkAnnotation
                 , formSparkles
                 ]

